﻿using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

namespace Comp376A2_9609695
{
    /// <summary>
    /// The score popup when points are earned
    /// </summary>
    class ScorePopup : Updateable, Drawable
    {
        private Vector2 position;
        private int value;
        SpriteFont font;
        private int decay;
        private bool dead;
        public bool isDead { get { return dead; } }

        public ScorePopup(Vector2 position, int value, SpriteFont font)
        {
            this.position = position;
            this.value = value;
            this.font = font;
            dead = false;
        }

        void Updateable.update(GameTime time, GameController control)
        {
            // The score decays and dies after a second and a half
            decay += time.ElapsedGameTime.Milliseconds;
            if (decay > 1500 || control.state != GameController.GameState.Game)
                dead = true;
        }

        Texture2D Drawable.getImage()
        {
            return null;
        }

        void Drawable.draw(SpriteBatch renderer)
        {
            renderer.DrawString(font, value + "", position, Color.White);
        }
    }
}
